Skip to content

feat: update core MCP library to mark3labs/mcp-go and add SSE support#113

Merged
akshaydeo merged 1 commit intomainfrom
06-23-feat_core_mcp_internals_optimised
Jun 23, 2025
Merged

feat: update core MCP library to mark3labs/mcp-go and add SSE support#113
akshaydeo merged 1 commit intomainfrom
06-23-feat_core_mcp_internals_optimised

Conversation

@Pratham-Mishra04
Copy link
Copy Markdown
Collaborator

Update MCP Client Library to mark3labs/mcp-go v0.32.0

This PR updates the MCP client library from metoro-io/mcp-golang v0.13.0 to mark3labs/mcp-go v0.32.0, which brings significant improvements to the MCP integration in Bifrost.

Key Changes

  • Added support for Server-Sent Events (SSE) connections alongside existing HTTP and STDIO connections
  • Improved connection management with proper context handling and cleanup
  • Streamlined MCP client initialization and tool registration
  • Removed dependency on local HTTP server port for tool hosting
  • Updated documentation with examples for all connection types
  • Simplified dependency tree by removing several unnecessary packages

Implementation Details

  • Refactored MCPManager to use the new client library's API
  • Updated connection types to include SSE alongside HTTP and STDIO
  • Renamed HTTPConnectionString to ConnectionString for both HTTP and SSE connections
  • Enhanced error handling and logging for all connection types
  • Added proper cleanup for all connection types including SSE context cancellation
  • Updated example code and documentation to reflect the new API

This update provides better performance, more connection options, and improved reliability for MCP tool integration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 23, 2025

Summary by CodeRabbit

  • New Features

    • Added support for Server-Sent Events (SSE) as a new MCP connection type, allowing real-time data streaming from external MCP clients.
    • Simplified MCP client configuration by unifying connection strings for HTTP and SSE types.
  • Documentation

    • Updated guides and examples to reflect SSE support, new configuration fields, and troubleshooting for SSE connections.
    • Enhanced architecture diagrams and usage examples to include SSE clients.
  • Refactor

    • Migrated MCP integration to a new underlying library, improving connection handling and tool registration.
    • Streamlined process management and context handling for all MCP connection types.
  • Chores

    • Reduced and updated project dependencies for improved maintainability.
  • Tests

    • Added new test configurations to validate SSE MCP client integration.

Walkthrough

This update migrates the MCP integration from the metoro-io/mcp-golang library to the new mark3labs/mcp-go library. It introduces support for Server-Sent Events (SSE) as a connection type, updates configuration fields, revises documentation, and refactors the MCP management logic and client handling throughout the codebase.

Changes

File(s) Change Summary
core/go.mod, tests/core-chatbot/go.mod Switched MCP library dependency, removed unused indirect dependencies, added test dependencies.
core/mcp.go Refactored MCP integration to use new library; replaced HTTP server with STDIO, added SSE support, updated APIs.
core/schemas/mcp.go Added SSE as a connection type, unified connection string fields, updated config struct and constants.
docs/mcp.md, transports/README.md Updated documentation and examples for new connection types, config fields, and usage patterns.
tests/core-chatbot/main.go Added an SSE MCP client configuration to test setup.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MCPManager
    participant MCPServer
    participant MCPClient (HTTP/STDIO/SSE)
    participant ExternalTool

    User->>MCPManager: Initiate tool execution
    MCPManager->>MCPClient (HTTP/STDIO/SSE): Send tool call request
    MCPClient (HTTP/STDIO/SSE)->>ExternalTool: Execute tool logic
    ExternalTool-->>MCPClient (HTTP/STDIO/SSE): Return tool result
    MCPClient (HTTP/STDIO/SSE)-->>MCPManager: Deliver tool result
    MCPManager-->>User: Return response
Loading

Possibly related PRs

Suggested reviewers

  • akshaydeo
  • danpiths

Poem

In the warren of code, a new path we tread,
With MCP’s fresh library, old bugs we shed.
Now SSE streams where HTTP once stood,
Connections unified, just as they should.
Bifrost’s bridge grows nimble, swift, and bright—
Hopping forward, all systems alight!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch 06-23-feat_core_mcp_internals_optimised

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Pratham-Mishra04 Pratham-Mishra04 changed the title feat: update MCP library from metoro-io/mcp-golang to mark3labs/mcp-go feat: update core MCP library to mark3labs/mcp-go and add SSE support Jun 23, 2025
@Pratham-Mishra04 Pratham-Mishra04 marked this pull request as ready for review June 23, 2025 17:30
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fae0b2e and 0af6a56.

⛔ Files ignored due to path filters (2)
  • core/go.sum is excluded by !**/*.sum
  • tests/core-chatbot/go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • core/go.mod (2 hunks)
  • core/mcp.go (21 hunks)
  • core/schemas/mcp.go (1 hunks)
  • docs/mcp.md (18 hunks)
  • tests/core-chatbot/go.mod (1 hunks)
  • tests/core-chatbot/main.go (1 hunks)
  • transports/README.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
docs/mcp.md

1370-1370: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (17)
tests/core-chatbot/go.mod (2)

31-31: LGTM: Testing utility dependencies added.

The addition of github.com/google/go-cmp and github.com/kr/pretty as indirect dependencies enhances testing capabilities and aligns with the MCP library update.

Also applies to: 35-35


39-39: Verify if the old MCP dependency can be removed.

The old github.com/metoro-io/mcp-golang v0.13.0 dependency is still present as an indirect dependency despite the migration to the new mark3labs/mcp-go library. This could indicate incomplete migration or dependency conflicts.

#!/bin/bash
# Check if the old MCP dependency is still being used anywhere in the codebase
echo "Searching for references to the old MCP library..."
rg -i "metoro-io/mcp-golang" --type go

echo -e "\nChecking go.mod files for the old dependency..."
fd "go.mod" --exec grep -l "metoro-io/mcp-golang" {}

echo -e "\nChecking for any imports of the old library..."
rg "github\.com/metoro-io/mcp-golang" --type go
core/go.mod (2)

9-9: LGTM: Clean migration to new MCP library.

Successfully migrated from metoro-io/mcp-golang to mark3labs/mcp-go v0.32.0, providing enhanced MCP capabilities including SSE support.


28-32: Verify new dependency versions are secure and current.

The new indirect dependencies introduced with the MCP library migration should be verified for security vulnerabilities and currency.

Are there any known security vulnerabilities in these Go packages and versions: github.com/google/uuid v1.6.0, github.com/spf13/cast v1.7.1, github.com/yosida95/uritemplate/v3 v3.0.2?
core/schemas/mcp.go (2)

15-15: LGTM: Unified connection string field design.

Replacing HTTPConnectionString with the more generic ConnectionString field that works for both HTTP and SSE connections is a clean design improvement that reduces schema duplication.


25-27: LGTM: Proper SSE support implementation.

The addition of MCPConnectionTypeSSE constant and updated documentation properly extends MCP connection types to support Server-Sent Events alongside existing HTTP and STDIO options.

transports/README.md (2)

121-124: LGTM: Documentation updated to reflect schema changes.

Correctly updated from "http_connection_string" to "connection_string" to match the unified schema design, and properly included the required empty arrays for tool configuration.


125-131: LGTM: Comprehensive SSE connection example.

The new SSE MCP client configuration provides a clear, practical example of how to use the Server-Sent Events connection type with proper field structure and naming conventions.

tests/core-chatbot/main.go (1)

251-256: LGTM: Proper SSE MCP client test configuration.

The new SSE MCP client configuration properly demonstrates the usage of MCPConnectionTypeSSE and provides practical test coverage for the Server-Sent Events functionality. The integration with existing configuration is clean and follows established patterns.

docs/mcp.md (3)

46-50: Great addition of SSE connection type documentation.

The documentation clearly explains the new Server-Sent Events connection type and its automatic cleanup behavior, which aligns well with the implementation in core/mcp.go.


134-138: Well-structured configuration examples for the new API.

The examples clearly demonstrate:

  • Migration from HTTPConnectionString to ConnectionString for HTTP connections
  • New SSE client configuration with proper structure
  • Consistent field naming across connection types

Also applies to: 190-202


419-425: API documentation is accurate and complete.

The struct definitions and constants correctly reflect the implementation:

  • ConnectionString field properly documented as required for HTTP/SSE
  • Envs field added to STDIO configuration
  • SSE connection type constant included

Also applies to: 991-997, 1008-1009, 1020-1023

core/mcp.go (5)

8-18: Excellent migration to the new MCP library with proper SSE support.

The changes effectively:

  • Update imports to use mark3labs/mcp-go
  • Add slices package for cleaner slice operations
  • Include cancelFunc for proper SSE connection cleanup
  • Update server and client types to match the new library

Also applies to: 46-60


474-483: Well-designed connection lifecycle management for different transport types.

The implementation correctly:

  • Handles SSE as a new connection type
  • Uses long-lived contexts for SSE connections (persistent streams)
  • Uses timeout contexts for HTTP/STDIO connections
  • Stores cancel functions for proper SSE cleanup

Also applies to: 490-510, 552-557


826-905: Clean implementation of transport-specific connection methods.

The connection creation methods are well-designed:

  • Clear separation of concerns for each transport type
  • Proper environment variable validation for STDIO
  • Consistent error handling and connection info structure
  • Appropriate use of the new library's transport APIs

907-954: Excellent cleanup implementation with proper resource management.

The cleanup method thoroughly:

  • Cancels SSE contexts before closing connections (critical for SSE)
  • Closes all client transport connections
  • Clears tool maps and client references
  • Properly logs all cleanup operations
  • Handles errors gracefully without failing the entire cleanup

244-276: Smart architectural change to STDIO-based local server.

The migration from HTTP to STDIO for the local server:

  • Eliminates port configuration complexity
  • Simplifies in-process communication
  • Reduces potential port conflicts
  • Maintains the same functionality with less overhead

Also applies to: 309-375

Comment thread docs/mcp.md
Comment thread core/mcp.go
@akshaydeo akshaydeo merged commit d31595a into main Jun 23, 2025
2 checks passed
@akshaydeo akshaydeo deleted the 06-23-feat_core_mcp_internals_optimised branch August 31, 2025 17:30
akshaydeo added a commit that referenced this pull request Nov 17, 2025
…#113)

# Update MCP Client Library to mark3labs/mcp-go v0.32.0

This PR updates the MCP client library from `metoro-io/mcp-golang` v0.13.0 to `mark3labs/mcp-go` v0.32.0, which brings significant improvements to the MCP integration in Bifrost.

## Key Changes

- Added support for Server-Sent Events (SSE) connections alongside existing HTTP and STDIO connections
- Improved connection management with proper context handling and cleanup
- Streamlined MCP client initialization and tool registration
- Removed dependency on local HTTP server port for tool hosting
- Updated documentation with examples for all connection types
- Simplified dependency tree by removing several unnecessary packages

## Implementation Details

- Refactored `MCPManager` to use the new client library's API
- Updated connection types to include SSE alongside HTTP and STDIO
- Renamed `HTTPConnectionString` to `ConnectionString` for both HTTP and SSE connections
- Enhanced error handling and logging for all connection types
- Added proper cleanup for all connection types including SSE context cancellation
- Updated example code and documentation to reflect the new API

This update provides better performance, more connection options, and improved reliability for MCP tool integration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants